<?php
namespace wechat;
/**
 * error code
 * 仅用作类内部使用，不用于官方API接口的errCode码
 */
class ErrorCode {
  
  const OK                     = 0;
  const ValidateSignatureError = 40001;
  const ParseXmlError          = 40002;
  const ComputeSignatureError  = 40003;
  const IllegalAesKey          = 40004;
  const ValidateAppidError     = 40005;
  const EncryptAESError        = 40006;
  const DecryptAESError        = 40007;
  const IllegalBuffer          = 40008;
  const EncodeBase64Error      = 40009;
  const DecodeBase64Error      = 40010;
  const GenReturnXmlError      = 40011;
  
  protected static $errCode = array(
    '0'     => '执行成功',
    '40001' => '校验签名失败',
    '40002' => '解析xml失败',
    '40003' => '计算签名失败',
    '40004' => '非法的AESKey',
    '40005' => '校验AppID失败',
    '40006' => '加密AES失败',
    '40007' => '解密AES失败',
    '40008' => '公众平台发送的xml不合法',
    '40009' => 'Base64编码失败',
    '40010' => 'Base64解码失败',
    '40011' => '生成返回xml失败',
  );
  
  public static function getErrText($err) {
    return self::$errCode[$err] ?? '';
  }
}
